package com.in.mobilerechargedth.adapter;

import java.util.List;

import com.in.mobilerechargedth.R;
import com.in.mobilerechargedth.model.RechargeModel;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class FourthRechargeDetailScreenListViewAdapter extends BaseAdapter {

    List<RechargeModel> details;
    private LayoutInflater mInflater;

    public FourthRechargeDetailScreenListViewAdapter(List<RechargeModel> details,
            Context context) {
        super();
        this.details = details;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return details.size();
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return details.get(arg0);
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return arg0;
    }

    @Override
    public View getView(int arg0, View v, ViewGroup arg2) {
        // TODO Auto-generated method stub
        ViewHolder viewHolder = null;
        RechargeModel detail = details.get(arg0);

        if (v == null) {
            v = mInflater.inflate(R.layout.adapter_item_fourth_recharge_detail_screen, null);
            viewHolder = new ViewHolder();
            viewHolder.circle_name = (TextView) v.findViewById(R.id.txtCircleName);
            viewHolder.amount = (TextView) v.findViewById(R.id.txtAmount);
            viewHolder.validity = (TextView) v.findViewById(R.id.txtValidity);
            viewHolder.otherDetails = (TextView) v
                    .findViewById(R.id.txtOtherDetail);

            v.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) v.getTag();
        }

        viewHolder.circle_name.setText(detail.getCircleName());

        viewHolder.amount.setText(detail.getAmount());
        viewHolder.validity.setText(detail.getValidity());
        viewHolder.otherDetails.setText(detail.getOfferdetails());

        return v;
    }

    private class ViewHolder {
        TextView circle_name;
        TextView amount;
        TextView validity;
        TextView otherDetails;
    }
}
